var express = require('express');
var userctrl = require('../ctrls/users');
var multer = require('multer');
var path = require('path');
var router = express.Router();

var storage = multer.diskStorage({
    destination: (req, file, cb) => {
        cb(null, './public/head/');
    },
    filename: (req, file, cb) => {
        let ext = path.extname(file.originalname);
        cb(null, Date.now() + ext);
    }
});
var upload = multer({ storage: storage });

router.post('/login', userctrl.login);
router.post('/regist', upload.single('head'), userctrl.regist);
router.post('/updatephone', userctrl.updatephone);
router.post('/updateemail', userctrl.updateemail);
router.post('/updatepwd', userctrl.updatepwd);
router.post('/use', userctrl.use);
router.post('/updateuser', userctrl.updateuser);
router.post('/adduser', userctrl.adduser);
router.post('/deluser', userctrl.deluser);

module.exports = router;
